/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Core.CoreManager;
import DataAccess.PhieuMuon;
import DataAccess.PhieuTra;
import DataAccess.TacGia;
import java.util.Vector;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author My PC
 */
public class PhieuTraController extends CoreManager<PhieuTra> {
    private String[] columnNames = {"Mã phiếu trả","Mã độc giả","Ngày trả"};
    public PhieuTraController()
    { super();
    GetAllData("PhieuTra");
    }
    @Override
    public void SetcolumnNames()
    {
        super.columnNames=columnNames;
    }
    public void showData(JTable table)
    {
        GetAllData("PhieuTra");
        DefaultTableModel tableModel=new DefaultTableModel(columnNames, 0);
        table.setModel(tableModel);
       // int no=1;
        for(Object o: super.list)
        {
            PhieuTra tg=(PhieuTra)o;
            Vector oneRow=new Vector();
            oneRow.add(tg.getPhieuTraId());
            oneRow.add(tg.getDocGiaId());
            oneRow.add(tg.getNgayTra());
            tableModel.addRow(oneRow);
          //  System.out.println(tableModel.);
        }
    }
    public PhieuTra getPhieuTraByIndex(int index)
    {
        return (PhieuTra)list.get(index);
    }
    
      public int GetLastID()
    {
        if(!list.isEmpty())
        return ((PhieuTra)this.list.get(list.size()-1)).getPhieuTraId();
        else return 0;
        
    }
}